import java.util.Scanner;

public class Test {
    public static void HanNuoTa(int n,char a,char b,char c){
        if(n==1) {
            System.out.println("将1从" + a + "移到" + c);
        }else {
            HanNuoTa(n-1,a,c,b);
            System.out.println("将"+n+"从"+a+"移到"+c);
            HanNuoTa(n-1,b,a,c);
        }

    }
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
HanNuoTa(n,'A','B','C');
    }
}